#include "menuwindow.h"

MenuWindow::MenuWindow(QWidget *parent, QGLWidget *shareWidget) :
	QGLWidget(parent, shareWidget)
{
	windowWidth = 640;
	windowHeight = 480;
	setMinimumSize(windowWidth, windowHeight);
	myRenderer = NULL;
}

MenuWindow::~MenuWindow() {
	delete myRenderer;
}

void MenuWindow::initializeGL() {
	myRenderer = new CEGUI::OpenGLRenderer( 0 );
	new CEGUI::System( myRenderer );
}

void MenuWindow::paintGL() {
	//qglClearColor(Qt::black);
	//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	CEGUI::System::getSingleton().renderGUI();
}

void MenuWindow::resizeGL(int width, int height) {
	/*if (width<height) {
		height = width * windowHeight/windowWidth;
	}
	else {
		width = height * windowWidth/windowHeight;
	}*/

	glViewport(0, 0, width, height);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(-1, +1, +1, -1, 0.0, 15.0);
	glMatrixMode(GL_MODELVIEW);
}
